﻿#region [ Code Modification History ]

//*******************************************************************************************************
//  GZipBlockHeader.cs 
//
//  Code Modification History:
//  -----------------------------------------------------------------------------------------------------
//  15/01/2017 - V. Dennis Kholin
//       Generated original version of source code. 
//*******************************************************************************************************

#endregion

#region [ Using ] 

using System.IO;

#endregion

namespace GZipStreamTool.Base.Gzip
{
    /// <summary>
    ///     GZippedBlockHeader
    /// </summary>
    public class GZipBlockHeader
    {
        #region [ Constructors ]

        #endregion

        #region [ Methods ]

        /// <summary>
        ///     InitHeader
        /// </summary>
        /// <param name="fs"></param>
        public void InitHeader(FileStream fs)
        {
            var binternal = new byte[1];
            fs.Position = 0;
            for (var i = 0; i < 10; i++)
            {
                fs.Read(binternal, 0, binternal.Length);
                switch (i)
                {
                    case 0:
                        _id0 = binternal[0];
                        break;
                    case 1:
                        _id1 = binternal[0];
                        break;
                    case 2:
                        ID2 = binternal[0];
                        break;
                    case 3:
                        ID3 = binternal[0];

                        break;
                    case 4:
                        ID4 = binternal[0];
                        break;
                    case 5:
                        ID5 = binternal[0];
                        break;
                    case 6:
                        ID6 = binternal[0];
                        break;
                    case 7:
                        ID7 = binternal[0];
                        break;
                    case 8:
                        ID8 = binternal[0];
                        break;
                    case 9:
                        ID9 = binternal[0];
                        break;
                }
            }
            fs.Position = 0;
        }

        #endregion

        #region [ Members Static ]

        private static byte _id0 = 0x1F;
        private static byte _id1 = 0x8B;


        // static byte ID3 = 0x08; //compression methods
        //  static byte ID4 = 0; // zero for now
        //  private static byte ID5 = 0; //zero for now
        //  static int BUFFER_SIZE = 64 * 1024; //64 Kb

        #endregion

        #region [ Properties ]

        /// <summary>
        ///     ID0
        /// </summary>
        public byte ID0
        {
            get { return _id0; }
        }

        /// <summary>
        ///     ID1
        /// </summary>
        public byte ID1
        {
            get { return _id1; }
        }

        /// <summary>
        ///     ID2
        /// </summary>
        public byte ID2 { get; private set; }

        /// <summary>
        ///     ID3
        /// </summary>
        public byte ID3 { get; private set; }

        /// <summary>
        ///     ID4
        /// </summary>
        public byte ID4 { get; private set; }

        /// <summary>
        ///     ID5
        /// </summary>
        public byte ID5 { get; private set; }

        /// <summary>
        ///     ID6
        /// </summary>
        public byte ID6 { get; private set; }

        /// <summary>
        ///     ID7
        /// </summary>
        public byte ID7 { get; private set; }

        /// <summary>
        /// ID8
        /// </summary>
        public byte ID8 { get; private set; }

        /// <summary>
        /// ID9
        /// </summary>
        public byte ID9 { get; private set; }
        #endregion
    }
}